<div class="panel panel-default panel-intro">
    {:build_heading()}
    <script src="https://g.csdnimg.cn/lib/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('dxmianfeixian/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('dxmianfeixian/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('dxmianfeixian/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                        

                        

                        <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('dxmianfeixian/recyclebin')?'':'hide'}" href="dxmianfeixian/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>

                        <a href="javascript:;" id="btn-accept1" class="btn btn-success btn-change btn-start" title="" ><i class="fa fa-play"></i>复制上月数据</a>

                        {:build_toolbar('import')}
                        <a href="/assets/免费线用户导入模板.xlsx" class="btn btn-success btn-export" title="{:__('Export')}" ><i class="fa fa-download"></i>{:__('下载模版')}</a>
                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
                            <i class="fa fa-dollar"></i>
                            <span class="extend">
                                    金额合计：<span id="money">0</span>

                             </span>
                        </a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                           data-operate-edit="{:$auth->check('dxmianfeixian/edit')}"
                           data-operate-del="{:$auth->check('dxmianfeixian/del')}"
                           width="100%">
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script>
    $(function() {
        // 接单按钮点击事件
        $('#btn-accept1').click(function() {
            var id = $(this).data('id');
            var $btn = $(this);

            layer.confirm('确认要接复制上个月的数据吗？', {
                title: '接单确认',
                btn: ['确认', '取消']
            }, function(index) {
                layer.close(index);

                $btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 复制中...');

                $.ajax({
                    url: '{:url("dxmianfeixian/copydata")}',
                    type: 'post',
                    data: {id: id},
                    dataType: 'json',
                    success: function(res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {icon: 1}, function() {
                                window.location.reload();
                            });
                        } else {
                            layer.alert(res.msg, {icon: 2});
                            $btn.prop('disabled', false).html('<i class="fa fa-check"></i> 复制上月数据');
                        }
                    },
                    error: function() {
                        layer.alert('网络错误，请重试', {icon: 2});
                        $btn.prop('disabled', false).html('<i class="fa fa-check"></i> 复制上月数据');
                    }
                });
            });
        });
    });
</script>